export const on = (function () {
  if (document.addEventListener) {
    return function (element, event, handler) {
      if (element && event && handler) {
        element.addEventListener(event, handler, false)
      }
    }
  } else {
    return function (element, event, handler) {
      if (element && event && handler) {
        element.attachEvent('on' + event, handler)
      }
    }
  }
})()

export function changeMoney(num) {
  if(isNaN(num)) num = 0
  var regexp = /(?:\.0*|(\.\d+?)0+)$/
  if (num > 1000000) {
    num = JSON.stringify(num).slice(0, JSON.stringify(num).length - 4) / 100
    return num + '万'
  } else {
     if(num == 0){
      return '0.00'
     }
     num = (num / 100).toFixed(2)
     num = num.replace(regexp, '$1')
     return num
  }
 }